package com.chance.cc.crawler.development.bootstrap.sohu.carServise;

import com.chance.cc.crawler.core.CrawlerEnum;
import com.chance.cc.crawler.core.downloader.proxy.Proxy;
import com.chance.cc.crawler.core.filter.FilterUtils;
import com.chance.cc.crawler.core.record.CrawlerRequestRecord;
import com.chance.cc.crawler.development.controller.DevCrawlerController;

import static com.chance.cc.crawler.core.CrawlerEnum.CrawlerRequestType.internalDownload;
import static com.chance.cc.crawler.core.CrawlerEnum.CrawlerRequestType.supportSource;

public class SohuCarSeriesStart {

    private static Proxy proxy = new Proxy();
    static {
        //代理配置
        //H5168QRFNIU3804D
        //5F6B3610BB719FAA
        proxy.setHost("http-dyn.abuyun.com");
        proxy.setPort(9020);
        proxy.setUsername("HL89Q19E86E2987D");
        proxy.setPassword("71F33D94CE5F7BF2");
    }


    public static void main(String[] args) {
        String domain = "sohu";
        String site = "carSeries";
        String url = "http://db.auto.sohu.com/porsche-1109/1959";

        CrawlerRequestRecord crawlerRequestRecord = CrawlerRequestRecord.builder()
                .startPageRequest(domain, CrawlerEnum.CrawlerRequestType.turnPage)
                .domain(domain)
                .httpUrl(url)
                .recordKey(url)
                .releaseTime(System.currentTimeMillis())
                .filter(CrawlerEnum.CrawlerRecordFilter.key)
                .addFilterInfo(FilterUtils.memoryFilterKeyInfo(domain))
                .proxy(proxy)
                .build();

        crawlerRequestRecord.tagsCreator().bizTags().addDomain(domain);
        crawlerRequestRecord.tagsCreator().bizTags().addSite(site);

        CrawlerRequestRecord keywordRecord = CrawlerRequestRecord.builder()
                .startPageRequest("autohome_series_keyword",CrawlerEnum.CrawlerRequestType.turnPageItem)
                .httpUrl("http://192.168.1.217:9599/v1/meta/autohome/keys?site=series")
                .requestLabelTag(supportSource)
                .requestLabelTag(internalDownload)
                .build();

        DevCrawlerController.builder()
                .triggerInfo(domain, domain, System.currentTimeMillis(), domain)
                .crawlerRequestQueue(DevCrawlerController.devRequestQueue(domain))
                .consoleResultPipeline("kafka")
                .fileResultPipeline("kafka","E:\\logs\\搜狐Kafka-8-3_2.log",false)
                .crawlerThreadNum(10)
                .requestRecord(crawlerRequestRecord)
               .supportRecord(keywordRecord)//加载关键字
                .build("com.chance.cc.crawler.development.scripts.sohu")
                .start();
    }
}
